﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using PM.Controls;
using PM.Controls.Common;
using HealthManagement.Data.Model;
using HealthManagement.Data.Service;
using HealthManagement.Model;
using System.Threading;

namespace HealthManagement
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : PMWindow
    {
        public Action callBack;


        public MainWindow()
        {
            InitializeComponent();
            Application.Current.MainWindow = this;
            this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
            
        }


        public MainWindow(Action action)
            : this()
        {
            this.callBack = action;
        }

        public MainWindow(Action action,User user)
            : this()
        {
            this.callBack = action;

            Application.Current.Properties["loginUser"] = user;
            userName.Text = user.username;

            if (user is DoctorUser)
            {
                userRole.Text = " 医师";
            }
        }

        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            if (callBack != null)
            {
                this.callBack();
            }

        }

        

        private void RadButton_Click(object sender, RoutedEventArgs e)
        {
            ContentFrame.Source = new Uri("View/UserPanel.xaml", UriKind.Relative);
        }

        private void RadButton_Click_1(object sender, RoutedEventArgs e)
        {
            CardLogin win = new CardLogin(ContentFrame);
            win.ShowDialog();

        }

        private void RadButton_Click_2(object sender, RoutedEventArgs e)
        {

            ContentFrame.Source = new Uri("View/Index.xaml", UriKind.Relative);
        }

        private void RadButton_Click_3(object sender, RoutedEventArgs e)
        {
            ContentFrame.Source = new Uri("View/DoctorPanel.xaml", UriKind.Relative);
        }

        private void RadRadioButton_Checked(object sender, RoutedEventArgs e)
        {
            if (this.IsLoaded)
            {
                appearance.Visibility = Visibility.Visible;
                info.Visibility = Visibility.Collapsed;
                share.Visibility = Visibility.Collapsed;
            }
        }

        private void radRadioButton_Checked_1(object sender, RoutedEventArgs e)
        {

            appearance.Visibility = Visibility.Collapsed;
            info.Visibility = Visibility.Visible;
            share.Visibility = Visibility.Collapsed;
        }

        private void RadRadioButton_Checked_2(object sender, RoutedEventArgs e)
        {
            appearance.Visibility = Visibility.Collapsed;
            info.Visibility = Visibility.Collapsed;
            share.Visibility = Visibility.Visible;

        }

        private void RadButton_Click_4(object sender, RoutedEventArgs e)
        {

        }
    }
}
